import rclpy
from rclpy.node import Node
from base_interface_demo01.srv import AddInt
class AddIntServerNode(Node):
    def __init__(self):
        super().__init__('addint_server_node_py')
        self.get_logger().info('创建AddInt server Node')
        self.server=self.create_service(AddInt,'add_int',self.call_back_addint);
    def call_back_addint(self,req: AddInt.Request,resp: AddInt.Response):
        resp.sum=req.num1+req.num2
        self.get_logger().info(f'{req.num1}+{req.num2}={resp.sum}')
        return resp
def main():
    rclpy.init()
    rclpy.spin(AddIntServerNode())
    rclpy.shutdown()


if __name__ == '__main__':
    main()
